<?php

declare(strict_types=1);

namespace App\AdminApi\Modular\Administer\Validate;

use Core\Constants\Database;
use Zms\Validate\ValidateAbstract;

/**
 * 后台职位验证器
 */
class JobValidate extends ValidateAbstract
{
    public function rules(): array
    {
        return [
            ['id', 'required', 'error' => '数据异常，请刷新重试', 'on' => ['updated']],
            ['id', 'number', 'error' => '数据异常，请刷新重试', 'on' => ['updated']],

            ['name', 'required', 'error' => '请输入{label}', 'on' => ['created', 'updated']],
            ['name', 'string', 'max' => 10, 'error' => '{label}错误', 'on' => ['created', 'updated']],

            ['remarks', 'string', 'max' => 30, 'on' => ['created', 'updated']],

            ['sort', 'number', 'min' => Database::INT_MIN, 'max' => Database::INT_MAX, 'precision' => 0, 'on' => ['created', 'updated']],

            ['status', 'in', 'enums' => [0, 1], 'on' => ['created', 'updated']]
        ];
    }


    public function labels(): array
    {
        return [
            'name' => '职位名称',
            'auth' => '职位权限',
            'remarks' => '备注说明',
            'sort' => '排序',
            'status' => '职位状态'
        ];
    }
}